﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using iTeachSoft.Presentation.Code.Managers;
using iTeachSoft.Code.Managers;
using iTeachSoft.CoreObjects;

namespace iTeachSoft.Presentation.Controls
{
    /// <summary>
    /// Interaction logic for ControlProjectInfo.xaml
    /// </summary>
    public partial class ControlProjectInfo : UserControl
    {
        public ControlProjectInfo()
        {
            InitializeComponent();

            EventsManagement.Instance.ReflectProjectInvoked += new EventHandler(Instance_ReflectProjectInvoked);
        }

        void Instance_ReflectProjectInvoked(object sender, EventArgs e)
        {
            this.labelNoOfSlides.Content = "Current number of slides: " + RuntimeStorage.CurrentProject.Slides.Count.ToString();
            this.labelProjectName.Content = "Project name: " + RuntimeStorage.CurrentProject.Name.ToString();
            this.labelTotalTime.Content = "Total time: " + GetTotalTime();
        }

        private string GetTotalTime()
        {
            float totalSeconds = 0;
            foreach (Slide slide in RuntimeStorage.CurrentProject.Slides)
            {
                totalSeconds += slide.ShowSlideForSeconds;
            }

            TimeSpan time = new TimeSpan(0, 0, (int)totalSeconds);
            return time.ToString();
        }
    }
}
